// @vue/component
import {fetchList,fetchDetail} from  '@/api/access-log'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'AccessLog',

  components: { Pagination },

  mixins: [],

  props: {},

  data () {
    return {
      drawer: false,
      direction: 'rtl',
      formInline: {
        page_size: 10,
        page_num: 1,
        user_name: '',
        api_name: '',
        ip: '',
        start_date: '',
        end_date: ''
      },
      tableData: null,
      total: 0,
      listLoading: false,
      tempData: {

      }
    }
  },

  computed: {},

  watch: {},

  created () {
    this.getList()
  },

  methods: {

    listQuery(){

    },
    getList(){
      this.listLoading = true
      fetchList(this.formInline).then(response => {

        this.tableData = response.data.data
        this.total = response.data.page_info.count
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    showDetail(row){

      fetchDetail(row.id).then(response=>{
        this.drawer = true
        this.tempData = response.data.data
        console.log(row)
        console.log(this.tempData)
      })

    },
    handleDelete(row,index){
        console.log(row,index)
    }
  }
}
